import React, { Component, PropTypes } from 'react'


class CommonTitle extends Component{
	render(){
		const {text, showBack} = this.props;
		let display = 'none';
		if(showBack === true) {
            display = '';
		}
		return (
				<div  className="commonTitle"> <button style={{display: display}} className="back" onClick={this._Click.bind(this)}></button>{text} </div>
			)
	}
	_Click(){
		this.context.router.goBack();
	}
}

CommonTitle.propTypes = {
  text: PropTypes.string.isRequired,
  showBack: PropTypes.bool.isRequired
}
CommonTitle.contextTypes = {
    router:React.PropTypes.object
}

export default CommonTitle